<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>信审基础台账</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<form id="formSet1">
			<div class="fieldset1 tabel_col clearFix">
				<div class="fieldBox col_50" style="display: none">
					<div class="label">评审类别</div>
					<div class="field">
						<span name="reviewTypeCdNm" id="reviewTypeCdNm">${reviewTypeCdNm }&nbsp;</span>
						<input type="hidden" name="reviewTypeCd" id="reviewTypeCd" value="${reviewTypeCd }"/>
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">处理节点</div>
					<div class="field">
						<span name="taskName" id="taskName">${taskNm }&nbsp;</span>
					</div>
				</div>
				<div class="fieldBox col_50" style="display: none">
					<div class="label">原因分类</div>
					<div class="field">
						<select name="reasonTypeCd" id="reasonTypeCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${reasonTypeCdList }" var="mfr">
								<option value="${mfr.key }">${mfr.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_50" style="display: none">
					<div class="label">品牌级别</div>
					<div class="field">
						<select name="brandLevelCd" id="brandLevelCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${brandLevelCdList }" var="mfr">
								<option value="${mfr.key }">${mfr.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">是否首次立项</div>
					<div class="field">
						<select name="isNew" id="isNew" data-value=" " validate="{required:true,select:true}">
							<option value=" " checked >请选择</option>
							<c:forEach items="${yesOrNoCdList }" var="mfr">
								<option value="${mfr.key }">${mfr.value }</option>
							</c:forEach>
						</select>
						<span class="requiredSymbol">*</span>
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">流程审核意见</div>
					<div class="field">
						<select name="processOpinionCd" id="processOpinionCd" data-value=" ">
							<option value=" " checked >请选择</option>
							<c:forEach items="${processOpinionCdList }" var="mfr">
								<option value="${mfr.key }">${mfr.value }</option>
							</c:forEach>
						</select>
					</div>
				</div>
				<div class="fieldBox col_50" style="display: none">
					<div class="label">担保性质</div>
					<div class="field">
						<span name="guarantyProCdNm" id="guarantyProCdNm">${guarantyProCdNm }&nbsp;</span>
						<input name="guarantyProCd" id="guarantyProCd" type="hidden" value="${guarantyProCd }">
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">首付比例</div>
					<div class="field">
						<input name="firstPaymentPct" id="firstPaymentPct" type="text" class="ui-textbox" value="" validate="{number:true}">%
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">保证金比例</div>
					<div class="field">
						<input name="depositPct" id="depositPct" type="text" class="ui-textbox" value="" validate="{number:true}">%
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">融资总金额</div>
					<div class="field">
						<input name="financingAmt" id="financingAmt" data-tofix="2" type="text" class="ui-textbox" value="" validate="{number:true}">
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">收益率</div>
					<div class="field">
						<input name="returnPct" id="returnPct" data-tofix="2" type="text" class="ui-textbox" value="" validate="{number:true}">%
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">咨询费1</div>
					<div class="field">
						<input name="consultingOneAmt" id="consultingOneAmt" data-tofix="2" type="text" class="ui-textbox" value="" validate="{number:true}">
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">咨询费2</div>
					<div class="field">
						<input name="consultingTwoAmt" id="consultingTwoAmt" data-tofix="2" type="text" class="ui-textbox" value="" validate="{number:true}">
					</div>
				</div>
				<div class="fieldBox col_50">
					<div class="label">年利率</div>
					<div class="field">
						<input name="annualRatePct" id="annualRatePct" type="text" class="ui-textbox" value="" validate="{number:true}">%
					</div>
				</div>
				<!-- <div id="dyncPrdOperateDiv" class="fieldBox col_100_auto">
				</div> -->
			</div>
			<div class="btnsBox">
				<!-- initData后对其赋值 用于判断Add or Modify 并不用来初始化数据(初始化数据是根据流程ID和任务ID) -->
				<input name="bookId" id="bookId" type="hidden" value="">
			</div>
		</form>
	</div>

<script type="text/javascript">
var _projectId = '${projectId}'; //项目ID
var _proIntId = '${proIntId}';//流程ID
var _taskDefKey = '${taskDefKey}';//任务KEY
var _prdTypCd = '${prdTypCd}';//产品类型
var _taskName = '${taskNm}';//节点名称
var isDetail = '${isDetail}';
$(function(){
	$('#formSet1').ligerForm({
        validate : true
	});
	initData();
	//refreshDyncFild(_prdTypCd);
	if(isDetail==1){
		disabled();
	}
	SET_popupIframeHeight();
});
//定义父级调用事件
frameElement.dialog.onOk = function () {
	addBscBook();
}
frameElement.dialog.onCancel = function () {
     frameElement.dialog.close();
}
function disabled(){
	if(liger.get("isNew")){
		liger.get("isNew").setDisabled(true);
	}
	if(liger.get("processOpinionCd")){
		liger.get("processOpinionCd").setDisabled(true);
	}
	if(liger.get("firstPaymentPct")){
		liger.get("firstPaymentPct").setDisabled(true);
	}
	if(liger.get("depositPct")){
		liger.get("depositPct").setDisabled(true);
	}
	if(liger.get("financingAmt")){
		liger.get("financingAmt").setDisabled(true);
	}
	if(liger.get("returnPct")){
		liger.get("returnPct").setDisabled(true);
	}
	if(liger.get("consultingOneAmt")){
		liger.get("consultingOneAmt").setDisabled(true);
	}
	if(liger.get("consultingTwoAmt")){
		liger.get("consultingTwoAmt").setDisabled(true);
	}
	if(liger.get("annualRatePct")){
		liger.get("annualRatePct").setDisabled(true);
	}
}

//根据产品类型刷新动态字段
function refreshDyncFild(_prdTypCd){
	if(!_prdTypCd || _prdTypCd=='') return;
	var _bizTypCd = "PRD0001";
	var _bizCd = _prdTypCd;
	//刷新农机新增字段
	var _url_1 = '<%=path%>/audit/audStandingBook/toFarmDynamicFldPage.do';
	$("#dyncPrdOperateDiv").load(_url_1,{bizTypCd:_bizTypCd, bizCd:_bizCd},function(responseText,textStatus){
		$("#formSet1").check_ligerFormEditor();
		initData();
	});
}

	//请求后台数据 (项目ID/流程ID/任务KEY)
	function initData(){
	   	var _url = '<%=path%>/audit/audStandingBook/getAudBscBook.do';
	   	$.ajax({
	   		type: 'get',
	   		dataType:'json',
	   		data:{projectId:_projectId,proIntId:_proIntId,taskDefKey:_taskDefKey},
	   		url: _url,
	   		success:function(msg){
				if(msg.success == 1){
					setData(msg.data);//设置数据
				}else{
					$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				}
	   		}
	   	});
  	}
		
	//设置页面数据
    function setData(data){
    	$("#bookId").val(data.id);//台账ID
    	var form = liger.get("formSet1");
    	form.setData({
    		reasonTypeCd:data.audBasicsBookVO.reasonTypeCd,
    		brandLevelCd:data.audBasicsBookVO.brandLevelCd,
    		processOpinionCd:data.audBasicsBookVO.processOpinionCd,
    		policyCd:data.audBasicsBookVO.policyCd
    	});
    	if(data.audBasicsBookVO.isNew){
    		form.setData({
           		isNew:data.audBasicsBookVO.isNew.toString()
        	});
    	}
		 
    	//$("#reviewTypeCdNm").html(data.reviewTypeCdNm);//评审类型span
    	//$("#guarantyProCdNm").html(data.audBasicsBookVO.guarantyProCdNm);//担保性质span
    	//$("#guarantyProCd").val(data.audBasicsBookVO.guarantyProCd); //担保性质Cd
    	$("#firstPaymentPct").val(data.audBasicsBookVO.firstPaymentPct); //首付比例
    	$("#depositPct").val(data.audBasicsBookVO.depositPct); //保证金比例
    	$("#financingAmt").val(data.audBasicsBookVO.financingAmt); //融资总金额
    	$("#returnPct").val(data.audBasicsBookVO.returnPct); //收益率
    	$("#consultingOneAmt").val(data.audBasicsBookVO.consultingOneAmt); //咨询费1
    	$("#consultingTwoAmt").val(data.audBasicsBookVO.consultingTwoAmt); //咨询费2
    	$("#annualRatePct").val(data.audBasicsBookVO.annualRatePct); //咨询费2
    	$("#irrPct").val(data.audBasicsBookVO.irrPct); //IRR
    	$("#repaymentPeriod").val(data.audBasicsBookVO.repaymentPeriod); //大额还款期次
		
	};
	function addBscBook(){
		var form = liger.get("formSet1");
	    if (!form.valid()) {
	    	$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
            return false; 
        }
	    var data = form.getData();
		var id = $("#bookId").val();
	   	var url='<%=path%>/audit/audStandingBook/add.do';
	   	if(id != ""){
	    	url = '<%=path%>/audit/audStandingBook/modify.do';
	    	data["id"]= id;
	    }
	   	data["projectId"]= _projectId;//项目ID
	   	data["proIntId"]= _proIntId;//流程实例ID
	   	data["taskDefKey"]= _taskDefKey;//任务KEY
	   	data["taskName"]= _taskName;//任务KEY
	   	data["reviewTypeCd"]= $("#reviewTypeCd").val();//评审类别CD
	   	data["guarantyProCd"]= $("#guarantyProCd").val();//担保性质CD
	   	data["bookTypeCd"]= AuditConstant.AUD_BSC_BOOK_TYP_CD; //台账类型
	   	var wait_dialog;
	    $.ajax({
			type: 'post',
			dataType:'json',
			data:data,
			url: url,
			beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
			success:function(msg){
				wait_dialog.close();
				 if(msg.success == 1){
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
					 if(msg.data){
						 $("#bookId").val(msg.data);
					 }
					 frameElement.dialog.close();
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		})
	}
</script>



</body>
</html>
